<template>
  <div>

  </div>
</template>

<script lang="ts">
import { ref, defineComponent, getCurrentInstance,onMounted } from 'vue'
export default defineComponent({
  name: 'FuncRunTime',
  setup: () => {
    let {ctx}:any = getCurrentInstance();

    onMounted(() => {
        BinaryFuncRun();
    })

    const BinaryFuncRun = () =>{
        const showThree = (a:number,b:number,c:number) =>{
            console.log(a,b,c);
        }
        let filterTwoArgsShowThreeFn = ctx.$R.binary(showThree);
        console.log(filterTwoArgsShowThreeFn(1,2,3));
    }

    const Tap = () =>{
        let sayX = (x:any) => console.log('x is ',x);
        ctx.$R.tap(sayX)(100); // sayX()
    }

    const ascendWay = () =>{
        console.log("ascend:返回一个升序排列的比较函数,主要用于排序");
        const byAge = ctx.$R.ascend(ctx.$R.prop('age'));
        let people:any[] = [];
        let peopleByYoungesrFirst = ctx.$R.sort(byAge)(people);
    }

    const descend = () =>{
        console.log("descend:返回一个降序排列的比较函数,主要用于排序");
        const byAge = ctx.$R.descend(ctx.$R.prop('age'));
        let people:any[] = [];
        let peopleByOldestFirst = ctx.$R.sort(byAge)(people);
    }

    const constFunction = () =>{
      const t = ctx.$R.always('Tee');
      t(); // => 'Tree'
    }

    return { BinaryFuncRun,Tap,ascendWay,descend,constFunction }
  }
})
</script>

<style scoped>
a {
  color: #42b983;
}

label {
  margin: 0 0.5em;
  font-weight: bold;
}

code {
  background-color: #eee;
  padding: 2px 4px;
  border-radius: 4px;
  color: #304455;
}
</style>
